﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Linq.Expressions;

namespace System.Web.Mvc
{
    public static class Extensions
    {
        public static bool IsDebug(this HtmlHelper htmlHelper)
        {
            #if DEBUG
                        return true;
            #else 
                  return false; 
            #endif
        }

        public static string ServerTime(this HtmlHelper htmlHelper)
        {    
            string datePattern = @"M/d/yyyy hh:mm:ss tt";
            return DateTime.Now.ToString(datePattern);
        } 

        public static SelectList ToSelectList<TEnum>(this TEnum enumObj)
        {
            var values = from TEnum e in Enum.GetValues(typeof(TEnum))
                         select new { Id = e, Name = e.ToString() };

            return new SelectList(values, "Id", "Name", enumObj);
        }

    }
}